﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

public class Solution73
{
    //使用一个visted数组，之前是0的才行列变为0 ，新变的不要变
    public void SetZeroes(int[][] matrix)
    {

        int m = matrix.Length;
        int n = matrix[0].Length;

        bool[][] visted = new bool[m][];
        for (int i = 0; i < m; i++)
        {
            visted[i] = new bool[n];
        }
        for (int i = 0; i < m; i++)
        {

            for (int j = 0; j < n; j++)
            {

                if (matrix[i][j] == 0&& visted[i][j]==false)
                {
                    //变换0

                    for(int row = 0; row < m; row++)
                    {

                        if(matrix[row][j] != 0)
                        {
                            matrix[row][j] = 0;


                            visted[row][j] = true;
                        }
                       

                    }


                    for (int col = 0; col < n; col++)
                    {
                        if (matrix[i][col] != 0)
                        {
                            matrix[i][col] = 0;
                            visted[i][col] = true;
                        }
                    }

                }



               
            }

         



        }


    }
}
class Program73
{





    static void Main73(string[] args)
    {


        //int[][] matrix = [[1, 1, 1], [1, 0, 1], [1, 1, 1]];
        int[][] matrix = [[0, 1, 2, 0], [3, 4, 5, 2], [1, 3, 1, 5]];
        Solution73 solution = new Solution73();
        solution.SetZeroes(matrix);

        for (int i = 0; i < matrix.Length; i++)
        {




            for (int j = 0; j < matrix[i].Length; j++)
            {


                Console.Write(matrix[i][j] + ",");
            }

            Console.WriteLine();


        }


    }
}



